package com.wongoing.api.wechat.pub.entity;

import java.io.Serializable;
import java.util.List;

/**
 * 功能说明：菜单实体类 修改说明：
 * 
 * @author zhenglibing
 * @date 2018年1月8日 下午3:05:23
 * @version 0.1
 */
public class Menu implements Serializable {

	private MenuType type;				//菜单类型
	private String name;				//菜单名称
	private String key;					//菜单KEY值
	private String url;					//网页链接
	private String appid;				//微信小程序appid
	private String pagepath;			//打开小程序的页面路径
	private List<Menu> sub_button;		//子菜单

	public MenuType getType() {
		return type;
	}

	public void setType(MenuType type) {
		this.type = type;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getKey() {
		return key;
	}

	public void setKey(String key) {
		this.key = key;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getAppid() {
		return appid;
	}

	public void setAppid(String appid) {
		this.appid = appid;
	}

	public String getPagepath() {
		return pagepath;
	}

	public void setPagepath(String pagepath) {
		this.pagepath = pagepath;
	}

	public List<Menu> getSub_button() {
		return sub_button;
	}

	public void setSub_button(List<Menu> sub_button) {
		this.sub_button = sub_button;
	}
	
	/**
	 * 功能说明：获取对象的json字符串
	 * 修改说明：
	 * @author zhenglibing
	 * @date 2018年1月8日 下午3:13:42
	 * @return 返回对象的json字符串
	 */
	public String toJsonString() {
		StringBuffer sb = new StringBuffer();
        sb.append("{");
        if (null != this.type)
        {
            sb.append("\"type\":\"").append(this.type.toString().toLowerCase()).append("\"").append(",");
        }
        sb.append("\"name\":\"").append(this.name).append("\"").append(",");
        if (null != this.key && !this.key.equals(""))
        {
            sb.append("\"key\":\"").append(this.key.trim()).append("\"").append(",");
        }
        if (null != this.url && !this.url.equals(""))
        {
            sb.append("\"url\":\"").append(this.url.trim()).append("\"").append(",");
        }
        if (null != this.appid && !this.appid.equals(""))
        {
            sb.append("\"appid\":\"").append(this.appid.trim()).append("\"").append(",");
        }
        if (null != this.pagepath && !this.pagepath.equals(""))
        {
            sb.append("\"pagepath\":\"").append(this.pagepath.trim()).append("\"").append(",");
        }
        sb.append("\"sub_button\":[");
        if (null != this.sub_button && this.sub_button.size() > 0)
        {
            for (int i = 0; i < this.sub_button.size(); i++)
            {
                if (i > 0)
                {
                    sb.append(",");
                }
                sb.append(this.sub_button.get(i).toJsonString());
            }
        }
        sb.append("]");
        sb.append("}");
        return sb.toString();
	}
}
